function IEworkaround(){

var control_groupName_array = ["controllo_group_0","controllo_group_2","controllo_group_4","controllo_group_6"];
var angle=-45;
var Dx=-30;
for (i in control_groupName_array) { 
var control_group_div=document.getElementById(control_groupName_array[i]);
var radangle=angle*Math.PI/180;
var cosangle=Math.cos(radangle);
var negcosangle=-Math.cos(radangle);
var sinangle=Math.sin(radangle);
var negsinangle=-Math.sin(radangle);
var matrix = $M([
      [cosangle, negsinangle,Dx],
      [sinangle, cosangle, 0],
      [0, 0, 1]
    ]);
transformOrigin(control_group_div, matrix);
control_group_div.style.filter="progid:DXImageTransform.Microsoft.Matrix(M11="+cosangle+", M12="+negsinangle+", M21="+sinangle+", M22="+cosangle+", SizingMethod = 'auto expand')";
fixIeBoundaryBug1(control_group_div, matrix);
angle=angle*(-1);
if (i==1) { 
	Dx=Dx*(-1);
}
Dx=Dx*(-1);
var stop;
}

/*
var a1;
a1=document.getElementById("controllo_group_0");
var width1;
width1=a1.clientWidth;
var height1;
height1=a1.clientHeight;
var angle1 = -45;
var Dx1;
var Dy1;
var radangle1=angle1*Math.PI/180;
var cosangle1=Math.cos(radangle1);
var negcosangle1=-Math.cos(radangle1);
var sinangle1=Math.sin(radangle1);
var negsinangle1=-Math.sin(radangle1);
Dx1=(-width1/2)*cosangle1+(height1/2)*sinangle1+width1/2;
Dy1=(-width1/2)*sinangle1-(height1/2)*cosangle1+height1/2;
*/

/*
a.style.cssText="-ms-filter:'progid:DXImageTransform.Microsoft.Matrix(M11="+cosangle+", M12="+negsinangle+", M21="+sinangle+", M22="+cosangle+", Dx="+Dx+", Dy="+Dy+", SizingMethod = 'auto expand')'";
a.style.cssText="filter:progid:DXImageTransform.Microsoft.Matrix(M11="+cosangle+", M12="+negsinangle+", M21="+sinangle+", M22="+cosangle+", Dx="+Dx+", Dy="+Dy+", SizingMethod = 'auto expand')";
*/

/*
a.filters.item(0).M11=cosangle;
a.filters.item(0).M12=negsinangle;
a.filters.item(0).M21=sinangle;
a.filters.item(0).M22=cosangle;
a.style.position="absolute";
a.style.top = a.offsetTop+20;
a.style.left = a.offsetLeft-73;
*/

/*
var matrix1 = $M([
      [cosangle1, negsinangle1,150],
      [sinangle1, cosangle1, 0],
      [0, 0, 1]
    ]);
transformOrigin(a1, matrix1);

a1.style.filter="progid:DXImageTransform.Microsoft.Matrix(M11="+cosangle1+", M12="+negsinangle1+", M21="+sinangle1+", M22="+cosangle1+", SizingMethod = 'auto expand')";
//a1.style.filter="-ms-filter:'progid:DXImageTransform.Microsoft.Matrix(M11="+cosangle1+", M12="+negsinangle1+", M21="+sinangle1+", M22="+cosangle1+", SizingMethod = 'auto expand')'";

fixIeBoundaryBug1(a1, matrix1);
*/

// II CONTROLLO

/*
var a2;
a2=document.getElementById("controllo_group_2");
var width2;
width2=a2.clientWidth;
var height2;
height2=a2.clientHeight;
var angle2 = 45;
var Dx2;
var Dy2;
var radangle2=angle2*Math.PI/180;
var cosangle2=Math.cos(radangle2);
var negcosangle2=-Math.cos(radangle2);
var sinangle2=Math.sin(radangle2);
var negsinangle2=-Math.sin(radangle2);
Dx2=(-width2/2)*cosangle2+(height2/2)*sinangle2+width2/2;
Dy2=(-width2/2)*sinangle2-(height2/2)*cosangle2+height2/2;
*/

/*
a.style.cssText="-ms-filter:'progid:DXImageTransform.Microsoft.Matrix(M11="+cosangle+", M12="+negsinangle+", M21="+sinangle+", M22="+cosangle+", Dx="+Dx+", Dy="+Dy+", SizingMethod = 'auto expand')'";
a.style.cssText="filter:progid:DXImageTransform.Microsoft.Matrix(M11="+cosangle+", M12="+negsinangle+", M21="+sinangle+", M22="+cosangle+", Dx="+Dx+", Dy="+Dy+", SizingMethod = 'auto expand')";
*/

/*
a.filters.item(0).M11=cosangle;
a.filters.item(0).M12=negsinangle;
a.filters.item(0).M21=sinangle;
a.filters.item(0).M22=cosangle;
a.style.position="absolute";
a.style.top = a.offsetTop+20;
a.style.left = a.offsetLeft-73;
*/

/*
var matrix2 = $M([
      [cosangle2, negsinangle2, 30],
      [sinangle2, cosangle2, 0],
      [0, 0, 1]
    ]);
transformOrigin(a2, matrix2);  

a2.style.filter="progid:DXImageTransform.Microsoft.Matrix(M11="+cosangle2+", M12="+negsinangle2+", M21="+sinangle2+", M22="+cosangle2+", SizingMethod = 'auto expand')";
//a2.style.filter="-ms-filter:'progid:DXImageTransform.Microsoft.Matrix(M11="+cosangle2+", M12="+negsinangle2+", M21="+sinangle2+", M22="+cosangle2+", SizingMethod = 'auto expand')'";

fixIeBoundaryBug1(a2, matrix2);
*/
}

function transformOrigin(a, matrix) {
    // undo the filter
    var filter = a.style.filter;
    a.style.filter = '';
    
    // measure the element
    var width = a.clientWidth;
    var height = a.clientHeight;
    
    // re-do the filter
    a.style.filter = filter;
    
    // The destination origin
    toOrigin = {
        x: width * 0.5,
        y: height * 0.5
    };
    
    // The original origin
    fromOrigin = {
        x: 0,
        //x:width/2,
        y: 0
        //y: -height/2
    };
    
    // Multiply our rotation matrix against an x, y coord matrix
    var toCenter = matrix.x($M([
        [toOrigin.x],
        [toOrigin.y],
        [1]
    ]));
    var fromCenter = matrix.x($M([
        [fromOrigin.x],
        [fromOrigin.y],
        [1]
    ]));
    
    // Position the element
    // The double parse float simply keeps the decimals sane
    a.style.position= "relative";
    var app1=parseFloat(parseFloat((fromCenter.e(2, 1) - fromOrigin.y) - (toCenter.e(2, 1) - toOrigin.y)).toFixed(8));
    a.style.top=app1+ "px";
    var app2=parseFloat(parseFloat((fromCenter.e(1, 1) - fromOrigin.x) - (toCenter.e(1, 1) - toOrigin.x)).toFixed(8));
	a.style.left=app2+"px";

/*
a.filters.item(0).M11=cosangle;
a.filters.item(0).M12=negsinangle;
a.filters.item(0).M21=sinangle;
a.filters.item(0).M22=cosangle;
*/
//a.style.cssText="-ms-filter:'progid:DXImageTransform.Microsoft.Matrix(M11="+cosangle+", M12="+negsinangle+", M21="+sinangle+", M22="+cosangle+", SizingMethod = 'auto expand')'";
//a.style.cssText="filter:progid:DXImageTransform.Microsoft.Matrix(M11="+cosangle+", M12="+negsinangle+", M21="+sinangle+", M22="+cosangle+", SizingMethod = 'auto expand')";
//a.style.filter="progid:DXImageTransform.Microsoft.Matrix(M11="+cosangle+", M12="+negsinangle+", M21="+sinangle+", M22="+cosangle+" SizingMethod = 'auto expand')";
}

function fixIeBoundaryBug1(a, matrix) {
    // undo the filter
    var filter = a.style.filter;
    a.style.filter = '';
    
    // measure the element
    var x = a.clientWidth;
    var y = a.clientHeight;
    
    // re-do the filter
    a.style.filter = filter;
    
    // create corners for the original element
    var matrices = {
        tl: matrix.x($M([[0], [0], [1]])),
        bl: matrix.x($M([[0], [y], [1]])),
        tr: matrix.x($M([[x], [0], [1]])),
        br: matrix.x($M([[x], [y], [1]]))
    };
            
    var corners = {
        tl: {
            x: parseFloat(parseFloat(matrices.tl.e(1, 1)).toFixed(8)),
            y: parseFloat(parseFloat(matrices.tl.e(2, 1)).toFixed(8))
        },
        bl: {
            x: parseFloat(parseFloat(matrices.bl.e(1, 1)).toFixed(8)),
            y: parseFloat(parseFloat(matrices.bl.e(2, 1)).toFixed(8))
        },
        tr: {
            x: parseFloat(parseFloat(matrices.tr.e(1, 1)).toFixed(8)),
            y: parseFloat(parseFloat(matrices.tr.e(2, 1)).toFixed(8))
        },
        br: {
            x: parseFloat(parseFloat(matrices.br.e(1, 1)).toFixed(8)),
            y: parseFloat(parseFloat(matrices.br.e(2, 1)).toFixed(8))
        }
    };
    
    // Initialize the sides
    var sides = {
        top: 0,
        left: 0
    };
    
    // Find the extreme corners
    for (var pos in corners) {
        // Transform the coords
        var corner = corners[pos];
        
        if (corner.y < sides.top) {
            sides.top = corner.y;
        }
        if (corner.x < sides.left) {
            sides.left = corner.x;
        }
    }
     // ADDENDUM - same for top
    if (sides.left==0 && matrix.e(1, 3)>0) {
    	sides.left=matrix.e(1, 3);
    }
    
    // find the top and left we set earlier (the hard way)
    /*
    $elem.wrap('<div style="position: relative" />');
    var pos = $elem.position();
    $elem.unwrap();
    */
   var dx = parseFloat(a.style.left);
   //dx=+23;
   //dx+=45;
   var dy = parseFloat(a.style.top);
   
    // Position the element
    a.style.top=dy + sides.top+ "px";
    a.style.left=dx + sides.left+ "px";

}
function fixIeBoundaryBug2(a, matrix) {
    // undo the filter
    var filter = a.style.filter;
    a.style.filter = '';
    
    // measure the element
    var x = a.clientWidth;
    var y = a.clientHeight;
    
    // re-do the filter
    a.style.filter = filter;
    
    // create corners for the original element
    var matrices = {
        tl: matrix.x($M([[0], [0], [1]])),
        bl: matrix.x($M([[0], [y], [1]])),
        tr: matrix.x($M([[x], [0], [1]])),
        br: matrix.x($M([[x], [y], [1]]))
    };
            
    var corners = {
        tl: {
            x: parseFloat(parseFloat(matrices.tl.e(1, 1)).toFixed(8)),
            y: parseFloat(parseFloat(matrices.tl.e(2, 1)).toFixed(8))
        },
        bl: {
            x: parseFloat(parseFloat(matrices.bl.e(1, 1)).toFixed(8)),
            y: parseFloat(parseFloat(matrices.bl.e(2, 1)).toFixed(8))
        },
        tr: {
            x: parseFloat(parseFloat(matrices.tr.e(1, 1)).toFixed(8)),
            y: parseFloat(parseFloat(matrices.tr.e(2, 1)).toFixed(8))
        },
        br: {
            x: parseFloat(parseFloat(matrices.br.e(1, 1)).toFixed(8)),
            y: parseFloat(parseFloat(matrices.br.e(2, 1)).toFixed(8))
        }
    };
    
    // Initialize the sides
    var sides = {
        top: 0,
        left: 0
    };
    
    // Find the extreme corners
    for (var pos in corners) {
        // Transform the coords
        var corner = corners[pos];
        
        if (corner.y < sides.top) {
            sides.top = corner.y;
        }
        if (corner.x < sides.left) {
            sides.left = corner.x;
        }
    }
    
    // ADDENDUM - same for top
    if (sides.left==0 && matrix.e(1, 3)>0) {
    	sides.left=matrix.e(1, 3);
    }
    
    // find the top and left we set earlier (the hard way)
    /*
    $elem.wrap('<div style="position: relative" />');
    var pos = $elem.position();
    $elem.unwrap();
    */
   var dx = parseFloat(a.style.left);
   var dy = parseFloat(a.style.top);
   
    // Position the element
    a.style.top=dy + sides.top+ "px";
    a.style.left=dx + sides.left+ "px";

}